//
//  LotteryOpenViewController.m
//  PlayBall
//
//  Created by Edward Zhang on 12-5-5.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddLotteryOpenViewController.h"
#import "JddCommonFunction.h"
#import "JddViewControllerManager.h"
#import "SBJson.h"
#import "NoticeViewController.h"

@interface JddLotteryOpenViewController ()

@end

@implementation JddLotteryOpenViewController

@synthesize code2;

SHARED_VIEW_CONTROLLER_IMPLEMENT(JddLotteryOpenViewController);

-(void)refresh2
{
    JddQueryLotteryOpenOperation *operation = [[JddQueryLotteryOpenOperation alloc] init];
    operation.delegate = self;
    [[JddGlobalParameter sharedInstance].operationQueue addOperation:operation];
    [JddCommonFunction setWaitingViewHidden:NO fromController:self];

}

- (void)lotteryOpenItemButtonClicked:(NSString *)code{
    
    if ([code isEqualToString:@"ShuangSeQiu"]) {

        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:shuangSeQiuCell.code2 
                                                                withObject2:nil];
    }
    else if ([code isEqualToString:@"DaLeTou"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:daLeTouCell.code2 
                                                                withObject2:nil];
    }
    else if ([code isEqualToString:@"ElevenSelectFive"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:elevenSelectFiveCell.code2 
                                                                withObject2:nil];
    }
    else if ([code isEqualToString:@"n11YDJ"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST
                                                             fromController:self
                                                                 withObject:n11YDJCell.code2
                                                                withObject2:nil];
    }
    else if ([code isEqualToString:@"cqss"]) {
//        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST
//                                                             fromController:self
//                                                                 withObject:cqssCell.code2
//                                                                withObject2:nil];
    }
    else if ([code isEqualToString:@"FootBall"]){
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_SPORT_RESULT 
                                                             fromController:self 
                                                                 withObject:nil 
                                                                withObject2:nil];
        
    }else if ([code isEqualToString:@"four"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:fc3dCell.code2 
                                                                withObject2:nil];
    }else if ([code isEqualToString:@"five"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:n7xCell.code2 
                                                                withObject2:nil];
    }else if ([code isEqualToString:@"six"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:pl3Cell.code2 
                                                                withObject2:nil];
    }else if ([code isEqualToString:@"seven"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:pl5Cell.code2 
                                                                withObject2:nil];
    }else if ([code isEqualToString:@"eight"]) {
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST 
                                                             fromController:self 
                                                                 withObject:n7lCell.code2 
                                                                withObject2:nil];
    }else if ([code isEqualToString:@"bd"]){
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_BD_RESULT fromController:self withObject:nil withObject2:nil];
        
        
    }else if ([code isEqualToString:@"jclq"]){
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_JCBB_RESULT fromController:self withObject:nil withObject2:nil];
    }else if(([code isEqualToString:@"sfc"])){
        [[JddViewControllerManager sharedInstance] pushViewControllerWithIndex:CONTROLLER_LOTTERY_OPEN_LIST
                                                             fromController:self
                                                                 withObject:sfcrx9Cell.code2
                                                                withObject2:nil];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70.0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return [cellArray count];
    return 12;//14
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
            return shuangSeQiuCell;
            break;
        case 1:
            return daLeTouCell;
            break;
        case 2:
            return elevenSelectFiveCell;
            break;
        case 3:
            return sportLotteryCell;
            break;
//        case 4:
//            return  bdCell;
//            break;
        case 4:
            return jclqCell;
            break;
        case 5:
            return sfcrx9Cell;
            break;
        case 6:
            return fc3dCell;
            break;
        case 7:
            return n7lCell;
            break;
        case 8:
            return pl3Cell;
            break;
        case 9:
            return pl5Cell;
            break;
        case 10:
            return n7xCell;
            break;
        case 11:
            return n11YDJCell;
            break;
//        case 13:
//            return cqssCell;
//            break;
        default:
            break;
    }
    
    return nil;
}

-(void)QueryLotteryOpenOperationResult:(NSData *)result{
    [JddCommonFunction setWaitingViewHidden:YES fromController:self];
    if (result) {
        NSString *cellResult = [JddDataParser parseSportLotteryIssueResult:result];
        SBJsonParser *jsonParse =  [[SBJsonParser alloc] init];
        cellArray = [jsonParse objectWithString:cellResult];
        for (NSDictionary *cellValue  in cellArray ) {
            if ([[cellValue objectForKey:@"WinNumber"] isEqualToString:@""]) {
                continue;
            }
            NSNumber *LotIDValue = [cellValue objectForKey:@"LottID"];
            if  ([LotIDValue intValue]== 5) {
                shuangSeQiuCell.button8.hidden= YES;
                    shuangSeQiuCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                    NSString *string3 = [cellValue objectForKey:@"WinNumber"];
                    NSArray *array2 = [string3 componentsSeparatedByString:@"+"];
                    NSMutableString *string4 = [array2 objectAtIndex:0];
                    NSMutableString *string5 = [array2 objectAtIndex:1];
                [shuangSeQiuCell.button7 setBackgroundImage:[UIImage imageNamed:@"jdd_bulebollselected.png"] forState:UIControlStateNormal];
                
                NSArray *array3 = [string4 componentsSeparatedByString:@" "];
                NSArray *array4 = [string5 componentsSeparatedByString:@" "];
                [shuangSeQiuCell.button1 setTitle:[array3 objectAtIndex:0] forState:UIControlStateNormal];
                [shuangSeQiuCell.button2 setTitle:[array3 objectAtIndex:1] forState:UIControlStateNormal];
                [shuangSeQiuCell.button3 setTitle:[array3 objectAtIndex:2] forState:UIControlStateNormal];
                [shuangSeQiuCell.button4 setTitle:[array3 objectAtIndex:3] forState:UIControlStateNormal];
                [shuangSeQiuCell.button5 setTitle:[array3 objectAtIndex:4] forState:UIControlStateNormal];
                [shuangSeQiuCell.button6 setTitle:[array3 objectAtIndex:5] forState:UIControlStateNormal];
                [shuangSeQiuCell.button7 setTitle:[array4 objectAtIndex:1] forState:UIControlStateNormal];
                [shuangSeQiuCell.button1 setEnabled:true];
                [shuangSeQiuCell.button2 setEnabled:true];
                [shuangSeQiuCell.button3 setEnabled:true];
                [shuangSeQiuCell.button4 setEnabled:true];
                [shuangSeQiuCell.button5 setEnabled:true];
                [shuangSeQiuCell.button6 setEnabled:true];
                [shuangSeQiuCell.button7 setEnabled:true];


                
                    if ([array2 count]>1) {
                        shuangSeQiuCell.WinNumberLabel.text = [NSString stringWithFormat:@"%@+",string4];
                        shuangSeQiuCell.WinNumberLabel2.text = [array2 objectAtIndex:1];
                    }else {
                        shuangSeQiuCell.WinNumberLabel.text = string4;
                        shuangSeQiuCell.WinNumberLabel2.text = @"";
                    }
            }
            else if  ([LotIDValue intValue]== 39) {
                daLeTouCell.button8.hidden = YES;
                    daLeTouCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                    NSString *string13 = [cellValue objectForKey:@"WinNumber"];
                    NSArray *array12 = [string13 componentsSeparatedByString:@"+"];
                    NSMutableString *string14 = [array12 objectAtIndex:0];
                NSMutableString *string4 = [array12 objectAtIndex:0];
                NSMutableString *string5 = [array12 objectAtIndex:1];
                [daLeTouCell.button7 setBackgroundImage:[UIImage imageNamed:@"jdd_bulebollselected.png"] forState:UIControlStateNormal];
                [daLeTouCell.button6 setBackgroundImage:[UIImage imageNamed:@"jdd_bulebollselected.png"] forState:UIControlStateNormal];
                NSArray *array3 = [string4 componentsSeparatedByString:@" "];
                NSArray *array4 = [string5 componentsSeparatedByString:@" "];
                [daLeTouCell.button1 setTitle:[array3 objectAtIndex:0] forState:UIControlStateNormal];
                [daLeTouCell.button2 setTitle:[array3 objectAtIndex:1] forState:UIControlStateNormal];
                [daLeTouCell.button3 setTitle:[array3 objectAtIndex:2] forState:UIControlStateNormal];
                [daLeTouCell.button4 setTitle:[array3 objectAtIndex:3] forState:UIControlStateNormal];
                [daLeTouCell.button5 setTitle:[array3 objectAtIndex:4] forState:UIControlStateNormal];
                [daLeTouCell.button6 setTitle:[array4 objectAtIndex:1] forState:UIControlStateNormal];
                [daLeTouCell.button7 setTitle:[array4 objectAtIndex:2] forState:UIControlStateNormal];
                [daLeTouCell.button1 setEnabled:true];
                [daLeTouCell.button2 setEnabled:true];
                [daLeTouCell.button3 setEnabled:true];
                [daLeTouCell.button4 setEnabled:true];
                [daLeTouCell.button5 setEnabled:true];
                [daLeTouCell.button6 setEnabled:true];
                [daLeTouCell.button7 setEnabled:true];
                    if ([array12 count]>1) {
                        daLeTouCell.WinNumberLabel.text = [NSString stringWithFormat:@"%@+",string14];
                        daLeTouCell.WinNumberLabel2.text = [array12 objectAtIndex:1];
                    }else {
                        daLeTouCell.WinNumberLabel.text = string14;
                        daLeTouCell.WinNumberLabel2.text = @"";
                    }
            }
            else if  ([LotIDValue intValue]== 70) {
                elevenSelectFiveCell.button6.hidden =YES;
                elevenSelectFiveCell.button7.hidden = YES;
                elevenSelectFiveCell.button8.hidden = YES;
                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
                NSArray *array1 = [string2 componentsSeparatedByString:@" "];
                if (array1.count > 0) {
                    [elevenSelectFiveCell.button1 setTitle:[array1 objectAtIndex:0] forState:UIControlStateNormal];
                    [elevenSelectFiveCell.button1 setEnabled:true];
                }
                if (array1.count > 1) {
                    [elevenSelectFiveCell.button2 setTitle:[array1 objectAtIndex:1] forState:UIControlStateNormal];
                    [elevenSelectFiveCell.button2 setEnabled:true];
                    }
                if (array1.count > 2) {
                    [elevenSelectFiveCell.button3 setTitle:[array1 objectAtIndex:2] forState:UIControlStateNormal];
                    [elevenSelectFiveCell.button3 setEnabled:true];
                }
                if (array1.count > 3) {
                    [elevenSelectFiveCell.button4 setTitle:[array1 objectAtIndex:3] forState:UIControlStateNormal];
                    [elevenSelectFiveCell.button4 setEnabled:true];
                }
                if (array1.count > 4) {
                    [elevenSelectFiveCell.button5 setTitle:[array1 objectAtIndex:4] forState:UIControlStateNormal];
                    [elevenSelectFiveCell.button5 setEnabled:true];
                }                
                elevenSelectFiveCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                elevenSelectFiveCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];                    
            }
            else if  ([LotIDValue intValue]== LOTTERY_TYPE_ID_11YDJ) {
                n11YDJCell.button6.hidden =YES;
                n11YDJCell.button7.hidden = YES;
                n11YDJCell.button8.hidden = YES;
                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
                NSArray *array1 = [string2 componentsSeparatedByString:@" "];
                [n11YDJCell.button1 setTitle:[array1 objectAtIndex:0] forState:UIControlStateNormal];
                [n11YDJCell.button2 setTitle:[array1 objectAtIndex:1] forState:UIControlStateNormal];
                [n11YDJCell.button3 setTitle:[array1 objectAtIndex:2] forState:UIControlStateNormal];
                [n11YDJCell.button4 setTitle:[array1 objectAtIndex:3] forState:UIControlStateNormal];
                [n11YDJCell.button5 setTitle:[array1 objectAtIndex:4] forState:UIControlStateNormal];
                [n11YDJCell.button1 setEnabled:true];
                [n11YDJCell.button2 setEnabled:true];
                [n11YDJCell.button3 setEnabled:true];
                [n11YDJCell.button4 setEnabled:true];
                [n11YDJCell.button5 setEnabled:true];
                n11YDJCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                n11YDJCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];
            }
            else if  ([LotIDValue intValue]== LOTTERY_TYPE_ID_CQSS) {
//                cqssCell.button6.hidden =YES;
//                cqssCell.button7.hidden = YES;
//                cqssCell.button8.hidden = YES;
//                
//                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
//                if (string2 != nil || string2.length != 0) {
//                    [cqssCell.button1 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(0, 1)]] forState:UIControlStateNormal];
//                    [cqssCell.button2 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(1, 1)]] forState:UIControlStateNormal];
//                    [cqssCell.button3 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(2, 1)]] forState:UIControlStateNormal];
//                    [cqssCell.button4 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(3, 1)]] forState:UIControlStateNormal];
//                    [cqssCell.button5 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(4, 1)]] forState:UIControlStateNormal];
//                    [cqssCell.button1 setEnabled:true];
//                    [cqssCell.button2 setEnabled:true];
//                    [cqssCell.button3 setEnabled:true];
//                    [cqssCell.button4 setEnabled:true];
//                    [cqssCell.button5 setEnabled:true];
//
//                }
//                cqssCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
//                cqssCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];
                
                
//                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
//                NSArray *array1 = [string2 componentsSeparatedByString:@","];
//                if (array1.count > 0) {
//                    [cqssCell.button1 setTitle:[array1 objectAtIndex:0] forState:UIControlStateNormal];
//                    [cqssCell.button1 setEnabled:true];
//                }
//                if (array1.count > 1) {
//                    [cqssCell.button2 setTitle:[array1 objectAtIndex:1] forState:UIControlStateNormal];
//                    [cqssCell.button2 setEnabled:true];
//                }
//                if (array1.count > 2) {
//                    [cqssCell.button3 setTitle:[array1 objectAtIndex:2] forState:UIControlStateNormal];
//                    [cqssCell.button3 setEnabled:true];
//                }
//                if (array1.count > 3) {
//                    [cqssCell.button4 setTitle:[array1 objectAtIndex:3] forState:UIControlStateNormal];
//                    [cqssCell.button4 setEnabled:true];
//                }
//                if (array1.count > 4) {
//                    [cqssCell.button5 setTitle:[array1 objectAtIndex:4] forState:UIControlStateNormal];
//                    [cqssCell.button5 setEnabled:true];
//                }
                

            
            }
            else if  ([LotIDValue intValue]== 6) {
                fc3dCell.button6.hidden =YES;
                fc3dCell.button7.hidden = YES;
                fc3dCell.button8.hidden = YES;
                fc3dCell.button4.hidden = YES;
                fc3dCell.button5.hidden = YES;
                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
                [fc3dCell.button1 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(0, 1)]] forState:UIControlStateNormal];
                [fc3dCell.button1 setEnabled:true];
                [fc3dCell.button2 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(1, 1)]] forState:UIControlStateNormal];
                [fc3dCell.button2 setEnabled:true];
                [fc3dCell.button3 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(2, 1)]] forState:UIControlStateNormal];
                [fc3dCell.button3 setEnabled:true];
                fc3dCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                fc3dCell.LotNameLabel.text = [cellValue objectForKey:@"LottName"];
                fc3dCell.code2 = [NSNumber numberWithInt:[[cellValue objectForKey:@"LottID"] intValue]];
                fc3dCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];                    
            }
            else if  ([LotIDValue intValue]== 3) {
                n7xCell.button8.hidden = YES;
                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
                [n7xCell.button1 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(0, 1)]] forState:UIControlStateNormal];
                [n7xCell.button2 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(1, 1)]] forState:UIControlStateNormal];
                [n7xCell.button3 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(2, 1)]] forState:UIControlStateNormal];
                [n7xCell.button4 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(3, 1)]] forState:UIControlStateNormal];
                [n7xCell.button5 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(4, 1)]] forState:UIControlStateNormal];
                [n7xCell.button6 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(5, 1)]] forState:UIControlStateNormal];
                [n7xCell.button7 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(6, 1)]] forState:UIControlStateNormal];
                [n7xCell.button1 setEnabled:true];
                [n7xCell.button2 setEnabled:true];
                [n7xCell.button3 setEnabled:true];
                [n7xCell.button4 setEnabled:true];
                [n7xCell.button5 setEnabled:true];
                [n7xCell.button6 setEnabled:true];
                [n7xCell.button7 setEnabled:true];
                
                n7xCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                n7xCell.LotNameLabel.text = [cellValue objectForKey:@"LottName"];
                n7xCell.code2 = [NSNumber numberWithInt:[[cellValue objectForKey:@"LottID"] intValue]];
                n7xCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];                            
            }
            else if  ([LotIDValue intValue]== 63) {
                pl3Cell.button6.hidden =YES;
                pl3Cell.button7.hidden = YES;
                pl3Cell.button8.hidden = YES;
                pl3Cell.button4.hidden = YES;
                pl3Cell.button5.hidden = YES;
                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
                [pl3Cell.button1 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(0, 1)]] forState:UIControlStateNormal];
                [pl3Cell.button2 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(1, 1)]] forState:UIControlStateNormal];
                [pl3Cell.button3 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(2, 1)]] forState:UIControlStateNormal];
                [pl3Cell.button1 setEnabled:true];
                [pl3Cell.button2 setEnabled:true];
                [pl3Cell.button3 setEnabled:true];
                pl3Cell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                pl3Cell.LotNameLabel.text = [cellValue objectForKey:@"LottName"];
                pl3Cell.code2 = [NSNumber numberWithInt:[[cellValue objectForKey:@"LottID"] intValue]];
                pl3Cell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];                           
            }
            else if  ([LotIDValue intValue]== 64) {
                pl5Cell.button6.hidden =YES;
                pl5Cell.button7.hidden = YES;
                pl5Cell.button8.hidden = YES;
                NSMutableString *string2 =  [cellValue objectForKey:@"WinNumber"];
                [pl5Cell.button1 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(0, 1)]] forState:UIControlStateNormal];
                [pl5Cell.button2 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(1, 1)]] forState:UIControlStateNormal];
                [pl5Cell.button3 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(2, 1)]] forState:UIControlStateNormal];
                [pl5Cell.button4 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(3, 1)]] forState:UIControlStateNormal];
                [pl5Cell.button5 setTitle:[NSString stringWithFormat:@"%@", [string2 substringWithRange:NSMakeRange(4, 1)]] forState:UIControlStateNormal];
                pl5Cell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                pl5Cell.LotNameLabel.text = [cellValue objectForKey:@"LottName"];
                pl5Cell.code2 = [NSNumber numberWithInt:[[cellValue objectForKey:@"LottID"] intValue]];
                pl5Cell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];
//                elevenSelectFiveCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];
//                n11YDJCell.WinNumberLabel.text = [cellValue objectForKey:@"WinNumber"];
            }
            else if  ([LotIDValue intValue]== 13) {
                n7lCell.IssueLabel.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                n7lCell.LotNameLabel.text = [cellValue objectForKey:@"LottName"];
                n7lCell.code2 = [NSNumber numberWithInt:[[cellValue objectForKey:@"LottID"] intValue]];
                
                NSString *string13 = [cellValue objectForKey:@"WinNumber"];
                NSArray *array12 = [string13 componentsSeparatedByString:@"+"];
                NSMutableString *string4 = [array12 objectAtIndex:0];
                NSMutableString *string5 = [array12 objectAtIndex:1];
                [n7lCell.button8 setBackgroundImage:[UIImage imageNamed:@"jdd_bulebollselected.png"] forState:UIControlStateNormal];
                
                NSArray *array3 = [string4 componentsSeparatedByString:@" "];
                NSArray *array4 = [string5 componentsSeparatedByString:@" "];
                [n7lCell.button1 setTitle:[array3 objectAtIndex:0] forState:UIControlStateNormal];
                [n7lCell.button2 setTitle:[array3 objectAtIndex:1] forState:UIControlStateNormal];
                [n7lCell.button3 setTitle:[array3 objectAtIndex:2] forState:UIControlStateNormal];
                [n7lCell.button4 setTitle:[array3 objectAtIndex:3] forState:UIControlStateNormal];
                [n7lCell.button5 setTitle:[array3 objectAtIndex:4] forState:UIControlStateNormal];
                [n7lCell.button6 setTitle:[array3 objectAtIndex:5] forState:UIControlStateNormal];
                [n7lCell.button7 setTitle:[array3 objectAtIndex:6] forState:UIControlStateNormal];
                [n7lCell.button8 setTitle:[array4 objectAtIndex:1] forState:UIControlStateNormal];
                [n7lCell.button1 setEnabled:true];
                [n7lCell.button2 setEnabled:true];
                [n7lCell.button3 setEnabled:true];
                [n7lCell.button4 setEnabled:true];
                [n7lCell.button5 setEnabled:true];
                [n7lCell.button6 setEnabled:true];
                [n7lCell.button7 setEnabled:true];
                [n7lCell.button8 setEnabled:true];
                if ([array12 count]>1) {
                    n7lCell.WinNumberLabel.text = [NSString stringWithFormat:@"%@",string4];
                    n7lCell.WinNumberLabel2.text = [array12 objectAtIndex:1];
                }else {
                    n7lCell.WinNumberLabel.text = string4;
                    n7lCell.WinNumberLabel2.text = @"";
                }

            }
            else if ([LotIDValue intValue] == 1){
                sfcrx9Cell.button1.hidden = YES;
                sfcrx9Cell.button2.hidden = YES;
                sfcrx9Cell.button3.hidden = YES;
                sfcrx9Cell.button4.hidden = YES;
                sfcrx9Cell.button5.hidden = YES;
                sfcrx9Cell.button6.hidden = YES;
                sfcrx9Cell.button7.hidden = YES;
                sfcrx9Cell.button8.hidden = YES;
                sfcrx9Cell.sfc_num_label.hidden = NO;
                sfcrx9Cell.sfc_issue_label.text = [NSString stringWithFormat:@"%d期", [[cellValue objectForKey:@"Issue"] intValue]];
                sfcrx9Cell.LotNameLabel.text = @"胜负彩/任选九";
                sfcrx9Cell.code2 = [NSNumber numberWithInt:[[cellValue objectForKey:@"LottID"] intValue]];
                sfcrx9Cell.sfc_num_label.text = [cellValue objectForKey:@"WinNumber"];
            }
            else if([LotIDValue intValue] == 19){

            }
            
        }
    }
    [self.listTabelView reloadData];
}
- (void)loadCell
{
    shuangSeQiuCell = [JddLotteryOpenItemTableCell getInstanceView];
    shuangSeQiuCell.LotterOpenImage.image = [UIImage imageNamed:@"双色球.png"];
    shuangSeQiuCell.code = @"ShuangSeQiu";
    shuangSeQiuCell.LotNameLabel.text = @"双色球";
    shuangSeQiuCell.UseoneLabel.text = @"开奖号码:";
    shuangSeQiuCell.code2 = [NSNumber numberWithInt:5];
    shuangSeQiuCell.delegate = self;
    
    daLeTouCell = [JddLotteryOpenItemTableCell getInstanceView];
    daLeTouCell.LotterOpenImage.image = [UIImage imageNamed:@"大乐透.png"];
    daLeTouCell.LotNameLabel.text = @"大乐透";
    daLeTouCell.code = @"DaLeTou";
    daLeTouCell.UseoneLabel.text = @"开奖号码:";
    daLeTouCell.code2 = [NSNumber numberWithInt:39];
    daLeTouCell.delegate = self;
    
    elevenSelectFiveCell = [JddLotteryOpenItemTableCell getInstanceView];
    elevenSelectFiveCell.LotterOpenImage.image = [UIImage imageNamed:@"11选5.png"];
    elevenSelectFiveCell.LotNameLabel.text = @"11选5";
    elevenSelectFiveCell.code = @"ElevenSelectFive";
    elevenSelectFiveCell.UseoneLabel.text = @"开奖号码:";
    elevenSelectFiveCell.code2 = [NSNumber numberWithInt:70];
    elevenSelectFiveCell.delegate = self;
    
    sportLotteryCell = [JddLotteryOpenItemTableCell getInstanceView];
    sportLotteryCell.LotterOpenImage.image = [UIImage imageNamed:@"football.png"];
    sportLotteryCell.LotterOpenImage.hidden = NO;
    sportLotteryCell.LotNameLabel.text = @"竞彩足球";
    sportLotteryCell.UsetwoLabel.text = @"赛果查询";
    sportLotteryCell.label1.hidden = NO;
    sportLotteryCell.label2.hidden = NO;
    sportLotteryCell.imageVS.hidden = NO;
    sportLotteryCell.button1.hidden = YES;
    sportLotteryCell.button2.hidden = YES;
    sportLotteryCell.button3.hidden = YES;
    sportLotteryCell.button4.hidden = YES;
    sportLotteryCell.button5.hidden = YES;
    sportLotteryCell.button6.hidden = YES;
    sportLotteryCell.button7.hidden = YES;
    sportLotteryCell.button8.hidden = YES;
    sportLotteryCell.code = @"FootBall";
    sportLotteryCell.delegate = self;
    
//    bdCell = [JddLotteryOpenItemTableCell getInstanceView];
//    bdCell.LotterOpenImage.image = [UIImage imageNamed:@"football.png"];
//    bdCell.LotterOpenImage.hidden = NO;
//    bdCell.LotNameLabel.text = @"北京单场";
//    bdCell.UsetwoLabel.text = @"赛果查询";
//    bdCell.label1.hidden = NO;
//    bdCell.label2.hidden = NO;
//    bdCell.imageVS.hidden = NO;
//    bdCell.button1.hidden = YES;
//    bdCell.button2.hidden = YES;
//    bdCell.button3.hidden = YES;
//    bdCell.button4.hidden = YES;
//    bdCell.button5.hidden = YES;
//    bdCell.button6.hidden = YES;
//    bdCell.button7.hidden = YES;
//    bdCell.button8.hidden = YES;
//    bdCell.code = @"bd";
//    bdCell.delegate = self;
    
    jclqCell = [JddLotteryOpenItemTableCell getInstanceView];
    jclqCell.LotterOpenImage.hidden = NO;
    jclqCell.LotterOpenImage.image = [UIImage imageNamed:@"basketball.png"];
    jclqCell.LotNameLabel.text = @"竞彩篮球";
    jclqCell.UsetwoLabel.text = @"赛果查询";
    jclqCell.label1.hidden = NO;
    jclqCell.label2.hidden = NO;
    jclqCell.imageVS.hidden = NO;
    jclqCell.button1.hidden = YES;
    jclqCell.button2.hidden = YES;
    jclqCell.button3.hidden = YES;
    jclqCell.button4.hidden = YES;
    jclqCell.button5.hidden = YES;
    jclqCell.button6.hidden = YES;
    jclqCell.button7.hidden = YES;
    jclqCell.button8.hidden = YES;
    jclqCell.code = @"jclq";
    jclqCell.delegate = self;
    jclqCell.label1.text = @"客队";
    jclqCell.label2.text = @"主队";
    
    sfcrx9Cell = [JddLotteryOpenItemTableCell getInstanceView];
    sfcrx9Cell.LotterOpenImage.hidden = NO;
    sfcrx9Cell.LotterOpenImage.image = [UIImage imageNamed:@"jdd_buy_main_sfc.png"];
    sfcrx9Cell.UseoneLabel.text = @"开奖号码:";
    sfcrx9Cell.code = @"sfc";
    sfcrx9Cell.button1.hidden = YES;
    sfcrx9Cell.button2.hidden = YES;
    sfcrx9Cell.button3.hidden = YES;
    sfcrx9Cell.button4.hidden = YES;
    sfcrx9Cell.button5.hidden = YES;
    sfcrx9Cell.button6.hidden = YES;
    sfcrx9Cell.button7.hidden = YES;
    sfcrx9Cell.button8.hidden = YES;
    sfcrx9Cell.sfc_num_label.hidden = NO;
    sfcrx9Cell.LotNameLabel.text = @"胜负彩/任选九";
    sfcrx9Cell.delegate = self;
    
    fc3dCell = [JddLotteryOpenItemTableCell getInstanceView];
    fc3dCell.LotterOpenImage.image = [UIImage imageNamed:@"福彩三D.png"];
    fc3dCell.UseoneLabel.text = @"开奖号码:";
    fc3dCell.code = @"four";
    fc3dCell.delegate = self;
    
    n7xCell = [JddLotteryOpenItemTableCell getInstanceView];
    n7xCell.LotterOpenImage.image = [UIImage imageNamed:@"七星彩.png"];
    n7xCell.UseoneLabel.text = @"开奖号码:";
    n7xCell.code = @"five";
    n7xCell.delegate = self;
    
    pl3Cell = [JddLotteryOpenItemTableCell getInstanceView];
    pl3Cell.LotterOpenImage.image = [UIImage imageNamed:@"排列三.png"];
    pl3Cell.UseoneLabel.text = @"开奖号码:";
    pl3Cell.code = @"six";
    pl3Cell.delegate = self;
    
    pl5Cell = [JddLotteryOpenItemTableCell getInstanceView];
    pl5Cell.LotterOpenImage.image = [UIImage imageNamed:@"排列五.png"];
    pl5Cell.UseoneLabel.text = @"开奖号码:";
    pl5Cell.code = @"seven";
    pl5Cell.delegate = self;
    
    n7lCell = [JddLotteryOpenItemTableCell getInstanceView];
    n7lCell.LotterOpenImage.image = [UIImage imageNamed:@"七乐彩.png"];
    n7lCell.UseoneLabel.text = @"开奖号码:";
    n7lCell.code = @"eight";
    n7lCell.delegate = self;
    
    n11YDJCell = [JddLotteryOpenItemTableCell getInstanceView];
    n11YDJCell.LotterOpenImage.image = [UIImage imageNamed:@"11选5.png"];
    n11YDJCell.LotNameLabel.text = @"十一运夺金";
    n11YDJCell.code = @"n11YDJ";
    n11YDJCell.UseoneLabel.text = @"开奖号码:";
    n11YDJCell.code2 = [NSNumber numberWithInt:LOTTERY_TYPE_ID_11YDJ];
    n11YDJCell.delegate = self;
    
//    cqssCell = [JddLotteryOpenItemTableCell getInstanceView];
//    cqssCell.LotterOpenImage.image = [UIImage imageNamed:@"11选5.png"];
//    cqssCell.LotNameLabel.text = @"重庆时时彩";
//    cqssCell.code = @"cqss";
//    cqssCell.UseoneLabel.text = @"开奖号码:";
//    cqssCell.code2 = [NSNumber numberWithInt:LOTTERY_TYPE_ID_CQSS];
//    cqssCell.delegate = self;
    

}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
//    [self.navigationItem setHidesBackButton:YES];
    
    cellArray = [NSMutableArray array];
    // Do any additional setup after loading the view from its nib.

    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
    customLab.backgroundColor = [UIColor clearColor];
    [customLab setText:PAGE_LOTTERY_OPEN];
    customLab.textAlignment = NSTextAlignmentCenter;
    
    [customLab setTextColor:[UIColor whiteColor]];
    customLab.font = [UIFont systemFontOfSize:19];
    self.navigationItem.titleView = customLab;
        
//    UIButton *ziXunBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    ziXunBtn.frame = CGRectMake(0, 0, 40, 30);
//    [ziXunBtn setTitle:@"资讯" forState:UIControlStateNormal];
//    ziXunBtn.titleLabel.font = [UIFont systemFontOfSize:15];
//    ziXunBtn.backgroundColor = [UIColor clearColor];
//    [ziXunBtn addTarget:self action:@selector(pushNewView) forControlEvents:UIControlEventTouchUpInside];
//    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:ziXunBtn];
//    self.navigationItem.rightBarButtonItem = rightItem;
    
    UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,0)];
    self.listTabelView.tableFooterView = v;
    [self.listTabelView setSeparatorColor:SeparatorLineColor];
    if (IOS7) {
        [self.listTabelView setSeparatorInset:UIEdgeInsetsZero];
    }
    
}
- (void)pushNewView
{
    NoticeViewController *noticeView = [[NoticeViewController alloc] init];
    [self.navigationController pushViewController:noticeView animated:YES];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [MobClick beginLogPageView:@"LotteryInfo"];
    [MobClick event:@"TAB-LotteryInfo"];

    [self.view setUserInteractionEnabled:YES];
    
    //显示tabbar
    [self setJddTabBarHidden:NO];
    [self setTabBarItemSelect:3];

    [self loadCell];
    [self refresh2];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"LotteryInfo"];
    
    [self setJddTabBarHidden:YES];
}

@end
